#ifndef CPP_MYWIDGET_H
#define CPP_MYWIDGET_H

#include "QtWidgets/QWidget"
#include "QtWidgets/QApplication"
#include "QtWidgets/QPushButton"
#include "QtWidgets/QVBoxLayout"
#include "QtCore/QDebug"
#include "QtCore/QJsonDocument"
#include "QtCore/QJsonObject"
#include "QtCore/QFile"
#include "QtCore/QDir"
#include "QtCore/QJsonArray"
#include "QtGui/QPixmap"
#include "QtNetwork/QNetworkAccessManager"
#include "QtNetwork/QNetworkRequest"
#include "QtNetwork/QNetworkReply"
#include "QtWidgets/QTextEdit"
#include "QtMultimedia/QMediaPlayer"


class MyWidget : public QWidget {
    Q_OBJECT
public:
    MyWidget(QWidget *parent = nullptr);
    void TextToSpeech();

private slots:
    void ShowTextToSpeechResult();
    void OnPlayButtonClicked();
    void OnPlayerStateChanged(QMediaPlayer::State state);

private:
    QJsonDocument GetTextToSpeechResult();
    QByteArray GetToken();

private:
    QPushButton *m_playButton = nullptr;
    QWidget *m_widget= nullptr;
    QTextEdit *m_textInputEdit = nullptr;
    QVBoxLayout *m_layout = nullptr;
    QByteArray m_token;
    QMediaPlayer *m_player;
    QString m_playIconPath;
    QString m_pauseIconPath;
    QString m_audioPath;
    bool m_audioSetFlag = true;
};

#endif // CPP_MYWIDGET_H